Selenium interview questions part 1/Selenium Interview Questions and Answers for Freshers & Experienced

Can WebDriver test mobile applications?

No, WebDriver is a testing tool used for web-based applications. So, we cannot test mobile applications with Selenium WebDriver.

Posted Date:- 2021-09-11 05:55:18

What is the difference between Assert and Verify in Selenium?

Assert: In simple words, if the assert condition is true then the program control will execute the next test step but if the condition is false, the execution will stop and further test step will not be executed.

Verify: In simple words, there won’t be any halt in the test execution even though the verify condition is true or false.

Posted Date:- 2021-09-11 05:53:53

What are the different types of waits available in WebDriver?

There are two types of waits available in WebDriver:

1. Implicit wait: These waits are used to provide a default waiting time (say, 30 seconds) between the consecutive test steps across the entire test script. Hence, the subsequent test step would only be executed when the 30 seconds are over after executing the previous test step.

2. Explicit wait: These waits are used to halt the execution until a particular condition is met or the maximum time has elapsed.

Posted Date:- 2021-09-11 05:51:45

What is the difference between setSpeed() and sleep() methods?

Both setSpeed() and Sleep() in Selenium are used to delay the speed of execution.

1) setSpeed: Sets the execution speed with a delay of milliseconds, followed by the Selenium operation. By default, the delay is 0 milliseconds.

2) sleep: Causes the suspension of execution of the current thread for a specified period.
That is all in the section of intermediate Selenium framework interview questions. Let’s move on to the next section of Selenium advanced interview questions.

Posted Date:- 2021-09-11 05:50:36

What is Selenese, and what are the three types of Selenese?

Selenese is a set of commands in Selenium used for running a test.

Three types of Selenese are as follows:

1). Actions: They are used for performing interactions and operations with the target elements.
2). Accessors: They are used for storing values in a variable.
3). Assertions: They are used as a checkpoint.

Posted Date:- 2021-09-11 05:49:29

Which WebDriver implementation claims to be the fastest?

The fastest implementation of WebDriver is the HTMLUnitDriver. It is because the HTMLUnitDriver does not execute tests in the browser. Starting a browser and running test cases took more time compared to running the scripts without a browser. HTMLUnitDriver took a simple HTTP request-response mechanism for test case execution.

Posted Date:- 2021-09-11 05:46:34

What is Selenium IDE?

Selenium IDE (Integrated Development Environment) is a Firefox plugin. It is the simplest framework in the Selenium Suite. It allows us to record and playback the scripts. Even though we can create scripts using Selenium IDE, we need to use Selenium RC or Selenium WebDriver to write more advanced and robust test cases.

Posted Date:- 2021-09-11 05:45:09

What are the different types of frameworks?

Below are the different types of frameworks:

Module Based Testing Framework: The framework divides the entire “Application Under Test” into the number of logical and isolated modules. For each module, we create a separate and independent test script. Thus, when these test scripts have taken together builds a larger test script representing more than one module.
Library Architecture Testing Framework: The basic fundamental behind the framework is to determine the common steps and group them into functions under a library and call those functions in the test scripts whenever required.
Data Driven Testing Framework: Data Driven Testing Framework helps the user segregate the test script logic and the test data from each other. It lets the user store the test data into an external database. The data is conventionally stored in “Key-Value” pairs. Thus, the key can be used to access and populate the data within the test scripts.
Keyword Driven Testing Framework: The Keyword Driven testing framework is an extension to Data-driven Testing Framework in a sense that it not only segregates the test data from the scripts, it also keeps the certain set of code belonging to the test script into an external data file.
Hybrid Testing Framework: Hybrid Testing Framework is a combination of more than one above mentioned frameworks. The best thing about such a setup is that it leverages the benefits of all kinds of associated frameworks.
Behavior Driven Development Framework: Behavior Driven Development framework allows automation of functional validations in an easily readable and understandable format to Business Analysts, Developers, Testers, etc.

Posted Date:- 2021-09-11 05:44:28

How to scroll down a page using JavaScript?

scrollBy() method is used to scroll down the webpage

General syntax:

executeScript("window.scrollBy(x-pixels,y-pixels)");

First, create a JavaScript object

JavascriptExecutor js = (JavascriptExecutor) driver;

Launch the desired application

driver.get(“https://www.amazon.com”);

Scroll down to the desired location

js.executeScript("window.scrollBy(0,1000)");

The window is not scrolled vertically by 1000 pixels

Posted Date:- 2021-09-11 05:42:25

What is the syntax of finding elements by id using CSS Selector?

By using #idValue in the CSS locator, we can select all the elements belonging to a particular class e.g. ‘#userId’ will select the element having an id – userId.

Posted Date:- 2021-09-11 05:41:36

What is the syntax of finding elements by class using CSS Selector?

By using .className in the CSS locator, we can select all the elements belonging to a particular class e.g. ‘.red’ will select all elements having class ‘red’.

Posted Date:- 2021-09-11 05:40:18

How many test cases you have automated per day?

Actually, it depends on Test case scenario complexity and length. I did automate 2-5 test scenarios per day when the complexity is limited. Sometimes just 1 or fewer test scenarios in a day when the complexity is high.

Posted Date:- 2021-09-11 05:39:31

What makes Selenium such a widely used testing tool? Give reasons.

1. Selenium is easy to use since it’s essentially developed in JavaScript.
2. Selenium can test web applications against browsers like Firefox, Opera, Chrome, and Safari, to name a few.
3. The test code can be written in various programming languages like Java, Perl, Python, and PHP.
4. Selenium is platform-independent, and can be deployed on different Operating systems like Windows, Linux, and Macintosh.
5. Selenium can be integrated with third-party tools like JUnit and TestNG for test management.

Posted Date:- 2021-09-11 05:38:05

What is the major difference between driver.close() and driver.quit()?

driver.close()

This command closes the browser’s current window. If multiple windows are open, the current window of focus will be closed.

driver.quit()

When quit() is called on the driver instance and there are one or more browser windows open, it closes all the open browser windows.

Posted Date:- 2021-09-11 05:32:19

Mention the types of navigation commands

driver.navigate().to("https://www.ebay.in/"); - Navigates to the provided URL

driver.navigate().refresh(); - This method refreshes the current page

driver.navigate().forward(); - This method does the same operation as clicking on the Forward Button of any browser. It neither accepts nor returns anything.

driver.navigate().back(); - This method does the same operation as clicking on the Back Button of any browser. It neither accepts nor returns anything.

Posted Date:- 2021-09-11 05:30:50

What are the features of TestNG and list some of the functionality in TestNG which makes it more effective?

TestNG is a testing framework based on JUnit and NUnit to simplify a broad range of testing needs, from Unit Testing to Integration Testing. And the functionality which makes it efficient testing framework are

1. Support for annotations
2. Support for data-driven testing
3. Flexible test configuration
4. Ability to re-execute failed test cases

Posted Date:- 2021-09-11 05:30:04

While using click command can you use screen coordinate?

To click on specific part of element, you would need to use clickAT command. ClickAt command accepts element locator and x, y co-ordinates as arguments-

clickAt (locator, cordString)

Posted Date:- 2021-09-11 05:28:32

What is the same-origin policy and how is it handled?

Same Origin policy is a feature adopted for security purposes. According to this policy, a web browser allows scripts from one webpage to access the contents of another webpage provided both the pages have the same origin. The origin refers to a combination of the URL scheme, hostname, and port number.

The same Origin Policy prevents a malicious script on one page to access sensitive data on another webpage.

Consider a JavaScript program used by google.com. This test application can access all Google domain pages like google.com/login, google.com/mail, etc. However, it cannot access pages from other domains like yahoo.com

Selenium RC was introduced to address this. The server acts as a client configured HTTP proxy and "tricks" the browser into believing that Selenium Core and the web application being tested come from the same origin.

Posted Date:- 2021-09-11 05:27:59

What is the difference between type keys and type commands ?

TypeKeys() will trigger JavaScript event in most of the cases whereas .type() won’t. Type key populates the value attribute using JavaScript whereas .typekeys() emulates like actual user typing.

Posted Date:- 2021-09-11 05:27:13

What is an absolute XPath?

An absolute XPath is a way of locating an element using an XML expression, beginning from the root node i.e. HTML node in the case of web pages.

The main disadvantage of absolute XPath is that even if there is a slight change in the UI or any element then also whole XPath will fail.

Example – html/body/div/div[2]/div/div/div/div[1]/div/input

Posted Date:- 2021-09-11 05:26:14

How can we inspect the web element attributes in order to use them in different locators?

In order to locate web elements, we can use the Developer tool and plugins like Firebug.
The developer tool can be launched by pressing F12 on the browser. Users can easily hover over any element and find its different HTML properties.

Firebug is a plugin of Firefox that provides various development tools for debugging applications. From an automation perspective, Firebug is used specifically for inspecting web elements in order to find their attributes like id, class, name, etc. in different locators.

Posted Date:- 2021-09-11 05:25:36

Can we test APIs or web services using Selenium Webdriver?

No. Selenium WebDriver uses the browser’s native method to automate the web applications. So, there is no support for testing web services using Selenium WebDriver.

Posted Date:- 2021-09-11 05:22:10

When do we use findElement() and findElements()?

findElement(): findElement() is used to find the first element in the current web page matching to the specified locator value. Take a note that only first matching element would be fetched.

Syntax:

WebElement element = driver.findElements(By.xpath(“//div[@id=’example’]//ul//li”));
findElements(): findElements() is used to find all the elements in the current web page matching to the specified locator value. Take a note that all the matching elements would be fetched and stored in the list of WebElements.

Syntax:
List <WebElement> elementList = driver.findElements(By.xpath(“//div[@id=’example’]//ul//li”));

Posted Date:- 2021-09-11 05:21:29

How to click on a hyper link using linkText?

driver.findElement(By.linkText(“Google”)).click();

The command finds the element using link text and then click on that element and thus the user would be re-directed to the corresponding page.

The above-mentioned link can also be accessed by using the following command.

driver.findElement(By.partialLinkText(“Goo”)).click();

The above command finds the element based on the substring of the link provided in the parenthesis and thus partialLinkText() finds the web element with the specified substring and then clicks on it.

Posted Date:- 2021-09-11 05:20:55

What are the different types of waits available in WebDriver?

There are two types of waits available in WebDriver:

1. Implicit Wait
2. Explicit Wait

Implicit Wait: Implicit waits are used to provide a default waiting time (say 30 seconds) between each consecutive test step/command across the entire test script. Thus, the subsequent test step would only execute when the 30 seconds have elapsed after executing the previous test step/command.

Explicit Wait: Explicit waits are used to halt the execution till the time a particular condition is met or the maximum time has elapsed. Unlike Implicit waits, explicit waits are applied for a particular instance only.

Posted Date:- 2021-09-11 05:20:15

What do we mean by Selenium 1 and Selenium 2?

Selenium RC and WebDriver, in a combination, are popularly known as Selenium 2. Selenium RC alone is also referred to as Selenium 1.

Posted Date:- 2021-09-11 05:19:39

What is Same origin policy and how it can be handled?

The problem of same origin policy disallows to access the DOM of a document from an origin that is different from the origin we are trying to access the document.

Origin is a sequential combination of scheme, host, and port of the URL. For example, for a URL https://www.softwaretestinghelp.com/resources/, the origin is a combination of http, softwaretestinghelp.com, 80 correspondingly.

Thus the Selenium Core (JavaScript Program) cannot access the elements from an origin that is different from where it was launched. For Example, if I have launched the JavaScript Program from “https://www.softwaretestinghelp.com”, then I would be able to access the pages within the same domain such as “https://www.softwaretestinghelp.com/resources” or “https://www.softwaretestinghelp.com/istqb-free-updates/”. The other domains like google.com, seleniumhq.org would no more be accessible.

So, In order to handle the same origin policy, Selenium Remote Control was introduced.

Posted Date:- 2021-09-11 05:19:15

What is the difference between assert and verify commands?

Assert: Assert command checks whether the given condition is true or false. Let’s say we assert whether the given element is present on the web page or not. If the condition is true then the program control will execute the next test step but if the condition is false, the execution would stop and no further test would be executed.

Verify: Verify command also checks whether the given condition is true or false. Irrespective of the condition being true or false, the program execution doesn’t halt i.e. any failure during verification would not stop the execution and all the test steps would be executed.

Posted Date:- 2021-09-11 05:18:48

When should I use Selenium IDE?

Selenium IDE is the simplest and easiest of all the tools within the Selenium Package. Its record and playback feature makes it exceptionally easy to learn with minimal acquaintances to any programming language. Selenium IDE is an ideal tool for a naïve user.

Posted Date:- 2021-09-11 05:16:49

What is the difference between getwindowhandles() and getwindowhandle()?

getwindowhandles(): It is used to get the address of all open browsers, and its return data type is Set<String>.


getwindowhandle(): It is used to get the address of the current browser where the control is, and its return type is a string data type.

Posted Date:- 2021-09-11 05:16:02

How will you use Selenium to upload a file?

If the file is on the same machine or in a mapped network drive, it is really straightforward: We have to just type the ‘path’ of the file in the FileUpload control.

Example:

driver = webdriver.Firefox()
element = driver.find_element_by_id("fileUpload")
element.send_keys("C:myfile.txt")

Posted Date:- 2021-09-11 05:15:25

What are data-driven framework and keyword-driven framework?

A data-driven framework in Selenium is an approach of separating a ‘dataset’ from the actual ‘test case’ (code). This framework is completely dependent on the input test data. The test data is inserted from external sources, such as from an Excel file, a CSV file, or from any database. It also allows us to easily control how much data needs to be tested. We can easily increase the number of test parameters by adding more username and password fields to the Excel file (or other sources).

A keyword-driven framework is an extension to the data-driven testing framework in the sense that it not only isolates the test data from the scripts but also keeps the particular section of the code belonging to the test script in an external data file. These sets of code are known as keywords, and hence the framework is so named. Keywords are self-guiding and work based on what actions need to be performed on the application.

Posted Date:- 2021-09-11 05:14:49

What is Same-origin Policy? How can we avoid it?

The ‘Same-origin Policy’ is introduced for security reasons.
>> It ensures that the content of our site will never be accessible by a script from another site.
>> As per the policy, any code loaded within the browser can only operate within that website’s domain.
>> To avoid this same-origin policy, the proxy injection method is used. In the proxy injection mode, Selenium Server tricks the browser to be a real HTTP URL, i.e., it acts as a client-configured HTTP proxy, which sits between the browser and the application under test (AUT) and then masks the AUT under a fictional URL.

Posted Date:- 2021-09-11 05:14:12

What are the four elements that you have to pass in Selenium?

Four parameters that need to be passed in Selenium are:

> Host
> Port number
> Browser
> URL

Posted Date:- 2021-09-11 05:13:30

Why do testers choose Selenium over QTP?

Selenium is more widely used than QTP since:

<> Selenium is an open-source tool, whereas QTP is a profitable tool
<> Selenium is used specifically for testing web-based applications, while QTP can be used for testing client–server applications too
<> Selenium supports multiple browsers like Firefox, IE, Opera, Safari, etc. and has multiple operating systems compatibility too. Selenium-supported OS platforms are Windows, Mac, Linux, etc. On the other hand, QTP is limited to Internet Explorer on Windows
<> Selenium supports multi-programming language compatibility. Languages supported by Selenium are Python, Ruby, Perl, etc. But, QTP supports only VBScript.

Posted Date:- 2021-09-11 05:12:57

What is POM (Page Object Model)? What are its advantages?

Page Object Model is a design pattern used to create object repositories for the web UI elements. Every web page of an application has a corresponding page class that is responsible for locating the web elements and performing actions on them.

Its advantages are as follows:

<> It provides support to separate operations and flows on the UI from verification, hence improving code readability.
<> As the object repository is independent of test cases, multiple tests can use the same object repository.
<> It increases the reusability of the code.

That’s all for the basic Selenium Java interview questions. Let’s move on to the next section of intermediate Selenium WebDriver interview questions.

Posted Date:- 2021-09-11 05:12:09

What is an exception test in Selenium?

An exception test is a test that looks forward to an exception to be thrown inside a test class. It anticipates the @Test annotation followed by the expected exception name. For example, @Test(expectedException = NoSuchElementException.class) is an exception test for missing elements in Selenium.

Posted Date:- 2021-09-11 05:11:25

What are the significant changes/upgrades made to various Selenium versions?

Selenium’s first version included only three sets of tools: Selenium IDE, Selenium RC, and Selenium Grid. There was no WebDriver included in the first version. Later, Selenium WebDriver was introduced and hence included in Selenium V2. However, as WebDriver got included, the use of Selenium RC was discouraged with time and is not much in use ever since. Selenium 3 is in use, and it has newly added features such as IDE and WebDriver. Selenium 4 is the latest released version.

Posted Date:- 2021-09-11 05:10:49

What is the difference between type keys and type commands?

TypeKeys() will trigger JavaScript events, while type() won’t. TypesKeys collects different value attributes using JavaScript. Whereas, the type commands imitate an actual user typing.

Posted Date:- 2021-09-11 05:09:38

What is an object repository?

An object repository allows testers to accumulate web elements of the application under test (AUT), along with their locator values, in one or more centralized locations as restricted to hard-coding them within the test scripts.

Posted Date:- 2021-09-11 05:09:14

Why should you use Selenium for test automation?

Selenium should be used for test automation as it:

<> Is a free and open-source tool
<> Has a large user base and community support
<> Has cross-browser compatibility (Firefox, Chrome, Internet Explorer, Safari, etc.)
<> Has great platform compatibility (Windows, Mac OS, Linux, etc.)
<> Supports multiple programming languages (Java, C#, Ruby, Python, Perl, etc.)
<> Has fresh and regular repository developments
<> Supports distributed testing

Posted Date:- 2021-09-11 05:08:50

Explain the difference between single slash and double slash in XPath.

1. Single slash (/): Single slash is used to create an XPath with an absolute path. In this case, the XPath would start selection from the document’s start node.

2. Double slash (//): Double slash is used to create an XPath with a relative path. In this case, the XPath would start selection from anywhere within the document.

Posted Date:- 2021-09-11 05:07:56

What is XPath?

While DOM is the recognized standard way for navigating through an HTML element tree, XPath is the navigation tool used to locate a web element based on its XML path.

XML stands for ‘Extensible Markup Language’ and is used to store, organize, and transport arbitrary data. It stores data in a key–value pair that is very much similar to HTML tags. Both being markup languages and falling under the same umbrella, XPath can be used to locate HTML elements.

The fundamental concept behind locating elements using XPath is traversing between various elements across the entire page and thus enabling a user to find an element with the reference of another element.

Posted Date:- 2021-09-11 05:07:20

Why should Selenium be selected as a test tool?

Selenium

> is a free and open source
> have a large user base and helping communities
> have cross Browser compatibility (Firefox, Chrome, Internet Explorer, Safari etc.)
> have great platform compatibility (Windows, Mac OS, Linux etc.)
> supports multiple programming languages (Java, C#, Ruby, Python, Pearl etc.)
> has fresh and regular repository developments
supports distributed testing

Posted Date:- 2021-09-11 05:06:36

List out the technical challenges with Selenium?

Technical challenges with Selenium are

<> Selenium supports only web based applications
<> It does not support the Bitmap comparison
<> For any reporting related capabilities have to depend on third party tools
<> No vendor support for tool compared to commercial tools like HP UFT
<> As there is no object repository concept in Selenium, maintainability of objects becomes difficult.

Posted Date:- 2021-09-11 05:04:58

What are the different forms of Selenium?

Selenium comes in four forms-

1. Selenium WebDriver – Selenium WebDriver is used to automate web applications by directly calling the browser’s native methods.
2. The Selenium IDE Plugin – Selenium IDE is an open-source test automation tool that works on record and playback principles.
3. Selenium RC component – Selenium Remote Control(RC) is officially deprecated by Selenium and it used to work using javascript to automate the web applications.
4. Selenium Grid – Allows Selenium tests to run in parallel across multiple machines.

Posted Date:- 2021-09-11 05:03:55

Explain the difference between single and double slash in X-path?

Single slash ‘/ ’

Single slash ( / ) start selection from the document node
It allows you to create ‘absolute’ path expressions


Double Slash ‘// ’

Double slash ( // ) start selection matching anywhere in the document
It enables to create ‘relative’ path expressions

Posted Date:- 2021-09-11 04:59:11

Mention what is the use of X-path?

X-Path is used to find the WebElement in web pages. It is also useful in identifying the dynamic elements.

Posted Date:- 2021-09-11 04:58:35

Explain what is assertion in Selenium and what are the types of assertion?

Assertion is used as a verification point. It verifies that the state of the application conforms to what is expected. The types of assertion are “assert” , “verify” and “waitFor”.

Posted Date:- 2021-09-11 04:58:11

How will you find an element using Selenium?

In Selenium every object or control in a web page is referred as an elements, there are different ways to find an element in a web page they are

ID
Name
Tag
Attribute
CSS
Linktext
PartialLink Text
Xpath etc

Posted Date:- 2021-09-11 04:57:44

What is Selenium and what is composed of?

Selenium is a suite of tools for automated web testing. It is composed of

Selenium IDE (Integrated Development Environment) : It is a tool for recording and playing back. It is a firefox plugin
WebDriver and RC: It provide the APIs for a variety of languages like Java, .NET, PHP, etc. With most of the browsers Webdriver and RC works.
Grid: With the help of Grid you can distribute tests on multiple machines so that test can be run parallel which helps in cutting down the time required for running in browser test suites.

Posted Date:- 2021-09-11 04:57:03

Search
R4R Team
R4R provides Selenium Freshers questions and answers (Selenium Interview Questions and Answers) .The questions on R4R.in website is done by expert team! Mock Tests and Practice Papers for prepare yourself.. Mock Tests, Practice Papers,Selenium interview questions part 1,Selenium Freshers & Experienced Interview Questions and Answers,Selenium Objetive choice questions and answers,Selenium Multiple choice questions and answers,Selenium objective, Selenium questions , Selenium answers,Selenium MCQs questions and answers R4r provides Python,General knowledge(GK),Computer,PHP,SQL,Java,JSP,Android,CSS,Hibernate,Servlets,Spring etc Interview tips for Freshers and Experienced for Selenium fresher interview questions ,Selenium Experienced interview questions,Selenium fresher interview questions and answers ,Selenium Experienced interview questions and answers,tricky Selenium queries for interview pdf,complex Selenium for practice with answers,Selenium for practice with answers You can search job and get offer latters by studing r4r.in .learn in easy ways .